using Boo.Lang.Compiler.Ast;
using Boo.Lang.Compiler.Steps;

namespace Mite.DSL
{
	/// <summary>
	/// Compiler step to run <see cref="DepthFirstTransformer"/>s.
	/// </summary>
	public class TransformerCompilerStep : AbstractVisitorCompilerStep
	{
		/// <summary>
		/// Creates an instance of TransformerCompilerStep.
		/// </summary>
		/// <param name="transformers">Transformers for this compiler step to run.</param>
		public TransformerCompilerStep(params DepthFirstTransformer[] transformers)
		{
			Guard.SequenceNotNullOrEmpty("transformers", transformers);
			this.transformers = transformers;
		}

		public override void Run()
		{
			foreach (DepthFirstTransformer transformer in transformers)
				transformer.Visit(CompileUnit);
		}

		private readonly DepthFirstTransformer[] transformers;
	}
}